Framework

A custom tool class based on the Base GMOD Toolgun, designed for integration with Lilia's framework.

The ToolGun class extends the functionality of the base GMOD toolgun, enabling seamless integration with Lilia's files and configuration. This custom tool class provides a flexible framework for creating and managing interactive tools within Garry's Mod, specifically tailored to work with Lilia's environment and system.

The ToolGun class is designed to work in conjunction with Lilia's file system and configuration setup. It allows for the implementation of toolguns that can be dynamically loaded and configured based on Lilia's files, offering a robust solution for extending tool functionalities in a modular way.

Customization and Flexibility:

The ToolGun class provides a foundation for creating custom tools that integrate smoothly with Lilia's system. Developers can extend and modify the class to fit specific needs, leveraging Lilia's configuration files to dictate tool behavior and appearance. This approach ensures that tools can be easily adapted and updated in line with Lilia's framework, providing a consistent and maintainable tool environment.

By integrating with Lilia's files, the ToolGun class enables developers to build sophisticated tools that are fully compatible with Lilia's system, enhancing the overall gameplay experience and tool management within Garry's Mod.

Functions

ToolGunMeta:Allowed()

Checks if the tool is allowed on the server. This method returns whether the tool is allowed based on the server convar AllowedCVar. It always returns true on the client-side.

Returns

  • any

    boolean True if the tool is allowed, false otherwise.

ToolGunMeta:BuildConVarList()

Builds a list of client-side convars. This method constructs a table of convars by appending the mode prefix to each convar name.

Returns

  • any

    table A table containing the mode-prefixed convars.

ToolGunMeta:CheckObjects()

Checks the validity of objects the tool is manipulating. This method iterates over the tool's objects and clears them if they are no longer valid, such as if the entity is no longer part of the world or is invalid.

ToolGunMeta:Create()

Creates a new tool object. This method initializes a new tool object with default properties. It sets up the metatable and various default values such as Mode, SWEP, Owner, ClientConVar, ServerConVar, Objects, Stage, Message, LastMessage, and AllowedCVar.

Returns

  • any

    table A new tool object with default properties.

ToolGunMeta:CreateConVars()

Creates client and server convars for the tool. This method generates convars (console variables) based on the tool's mode. Client convars are created on the client-side, while server convars are created on the server-side.

ToolGunMeta:Deploy()

Deploys the tool. This method is called when the player equips the tool. It releases any ghost entities associated with the tool.

ToolGunMeta:GetClientInfo(property)

Retrieves client-side information for a given property. This method returns the value of a client-side convar associated with the tool's mode.

Parameters

  • property String

    The name of the property to retrieve.

Returns

  • any

    string The value of the client convar.

ToolGunMeta:GetClientNumber(property, default)

Retrieves a numerical value from client-side convars. This method returns the value of a client-side convar as a number, or a default value if the convar does not exist.

Parameters

  • property String

    The name of the property to retrieve.

  • default number

    The default value to return if the convar is not found.

Returns

  • any

    number The numerical value of the client convar.

ToolGunMeta:GetMode()

Retrieves the mode of the tool. This method returns the current mode of the tool, which is a string representing the specific operation the tool is set to perform.

Returns

  • any

    string The current mode of the tool.

ToolGunMeta:GetOwner()

Retrieves the owner of the tool. This method returns the player who owns the tool by accessing the SWEP's Owner property.

Returns

  • any

    Player The player who owns the tool.

ToolGunMeta:GetSWEP()

Retrieves the SWEP (Scripted Weapon) associated with the tool. This method returns the SWEP object, which is typically the weapon the player is holding while using the tool.

Returns

  • any

    SWEP The SWEP object associated with the tool.

ToolGunMeta:GetServerInfo(property)

Retrieves server-side information for a given property. This method returns the value of a server-side convar associated with the tool's mode.

Parameters

  • property String

    The name of the property to retrieve.

Returns

  • any

    string The value of the server convar.

ToolGunMeta:GetWeapon()

Retrieves the weapon associated with the tool. This method returns the weapon associated with the tool by accessing the SWEP's Weapon property or the tool's own Weapon property.

Returns

  • any

    Weapon The weapon object associated with the tool.

ToolGunMeta:Holster()

Holsters the tool. This method is called when the player unequips the tool. It releases any ghost entities associated with the tool.

ToolGunMeta:Init()

Placeholder for initializing the tool. This method is intended to be overridden if initialization logic is needed when the tool is created.

ToolGunMeta:LeftClick()

Handles the left-click action with the tool. This method is intended to be overridden to define what happens when the player left-clicks with the tool. By default, it does nothing and returns false.

Returns

  • any

    boolean False by default, indicating no action was taken.

ToolGunMeta:Reload()

Handles the reload action with the tool. This method clears the objects that the tool is currently manipulating when the player reloads with the tool.

ToolGunMeta:RightClick()

Handles the right-click action with the tool. This method is intended to be overridden to define what happens when the player right-clicks with the tool. By default, it does nothing and returns false.

Returns

  • any

    boolean False by default, indicating no action was taken.

ToolGunMeta:Think()

Handles the tool's "think" logic. This method is called periodically to perform updates. By default, it releases any ghost entities associated with the tool.